package com.extension.company.view.localcity;

import android.app.Activity;
import android.content.Intent;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.extension.company.admin.R;
import com.extension.company.common.mvp.BaseTitleActivity;
import com.extension.company.contract.localcity.LocalCitySecondContract;
import com.extension.company.presenter.localcity.LocalCitySecondPresenter;
import com.extension.company.view.adapter.LocalCitySecondAdapter;
import com.extension.company.common.widget.EnhanceTabLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 作者:zwk
 * 联系方式：497981239@qq.com
 * 时间：on 2019/6/23 14:03
 * 功能：本地城市服务的二级actvitiy
 */
public class LocalCitySecondActivity extends BaseTitleActivity<LocalCitySecondContract.View, LocalCitySecondPresenter> implements LocalCitySecondContract.View {

	@BindView(R.id.local_tabLayout)
	EnhanceTabLayout tabLayout;
	@BindView(R.id.local_viewpager)
	ViewPager viewpager;
	private final String[] sTitle = {"推荐", "冰箱", "电视机", "空调", "洗衣机", "生活小电器", "笔记本"};
	private List<Fragment> fragmentList = new ArrayList<>();

	public static void startActivity(Activity activity) {
		Intent intent = new Intent(activity, LocalCitySecondActivity.class);
		activity.startActivity(intent);
	}

	@Override
	protected void initData() {
		for (int i = 0; i < sTitle.length; i++) {
			tabLayout.addTab(sTitle[i]);
			LocalCityFragment fragment = LocalCityFragment.getInstance();
			fragmentList.add(fragment);
		}
		viewpager.setAdapter(new LocalCitySecondAdapter(getSupportFragmentManager(), fragmentList));
		viewpager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout.getTabLayout()));
		tabLayout.setupWithViewPager(viewpager);
	}

	@Override
	protected void initListener() {

	}

	@Override
	public int getMainLayout() {
		return R.layout.local_city_second;
	}

	@Override
	public LocalCitySecondContract.View createView() {
		return this;
	}

	@Override
	public LocalCitySecondPresenter createPresenter() {
		return new LocalCitySecondPresenter();
	}

	@Override
	public void showLoading() {

	}

	@Override
	public void hideLoading() {

	}

	@Override
	public void onError(Throwable throwable) {

	}
}
